//
//  MarrayResultViewController.m
//  心水宝典
//
//  Created by zr on 2018/9/3.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MarrayResultViewController.h"

@interface MarrayResultViewController ()

@property (nonatomic, strong)UIImageView * backImageView;
@property (nonatomic, strong)UIImageView * topImageView;
@property (nonatomic, strong)UIImageView * oneImageView;
@property (nonatomic, strong)UILabel * topLabel;
@property (nonatomic, strong)UILabel * oneLabel;
@property (nonatomic, strong)UILabel * oneSubLabel;

@end

@implementation MarrayResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = WHITE_COLOR;
    
    [self setupNav];
    [self setupUI];
}

- (void)setupNav{
    
    self.title = @"八字合婚结果";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    //    backButton.frame = CGRectMake(0, 0, 20 * SCREENH6, 20 * SCREENH6);
    backButton.size = CGSizeMake(20 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
    
}

- (void)setupUI{
    
    self.backImageView = [self setupImageViewWithImage:@"bjdd"];
    [self.view addSubview:self.backImageView];
    self.topImageView = [self setupImageViewWithImage:@"biaoti"];
    [self.view addSubview:self.topImageView];
    self.oneImageView = [self setupImageViewWithImage:@"duobianxing"];
    [self.view addSubview:self.oneImageView];
    
    NSString * str = [NSString stringWithFormat:@"匹配度:%@",self.colligate_score];
    self.topLabel = [self setupLabelWithString:str WithType:@"title"];
    [self.topImageView addSubview:self.topLabel];
    self.oneLabel = [self setupLabelWithString:@"合婚详情" WithType:@"title"];
    [self.view addSubview:self.oneLabel];
    self.oneSubLabel = [self setupLabelWithString:self.colligate_content WithType:@"sub"];
    [self.view addSubview:self.oneSubLabel];
}


- (void)viewDidLayoutSubviews{
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(20 * SCREENH6);
        make.width.mas_equalTo(228 * SCREENH6);
        make.height.mas_equalTo(60 * SCREENH6);
    }];
    
    [self.topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.topImageView);
        make.centerY.mas_equalTo(self.topImageView);
    }];
    
    [self.oneImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
        make.top.mas_equalTo(self.topImageView.mas_bottom).offset(15 * SCREENH6);
        make.width.height.mas_equalTo(12 * SCREENH6);
    }];
    
    [self.oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.oneImageView);
        make.leading.mas_equalTo(self.oneImageView.mas_trailing).offset(5 * SCREENH6);
    }];
    
    [self.oneSubLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.oneImageView);
        make.trailing.mas_equalTo(self.view).offset(-15 * SCREENH6);
        make.top.mas_equalTo(self.oneImageView.mas_bottom).offset(10 * SCREENH6);
    }];
}


- (UIImageView *)setupImageViewWithImage:(NSString *)image{
    
    UIImageView * imageView = [UIImageView new];
    
    imageView.image = ImageNamed(image);
    
    return imageView;
}


- (UILabel *)setupLabelWithString:(NSString *)string WithType:(NSString *)type{
    
    UILabel * label = [UILabel new];
    
    label.textColor = BLACK_COLOR;
    label.text = string;
    label.numberOfLines = 0;
    if ([type isEqualToString:@"title"]) {
        
        label.font = [UIFont boldSystemFontOfSize:16 * SCREENH6];
    }else{
        
        label.font = [UIFont systemFontOfSize:15 * SCREENH6];
    }
    
    return label;
}



- (void)backToView {
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
